package com.ywd.platform.controller;

import com.ywd.platform.service.impl.VehicleTrackRecordServiceImpl;
import com.ywd.platform.vo.PointVo;
import com.ywd.platform.vo.VehicleTrackRecordOutVo;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * YWD
 * 2025/8/27
 */
@Slf4j
@AllArgsConstructor
@RestController
@RequestMapping("/record")
@Tag(name = "车辆定位管理")
public class VehicleTrackRecordController {

    private VehicleTrackRecordServiceImpl vehicleTrackRecordService;

    @GetMapping("/getVehicleTrackRecord")
    @Operation(summary = "getVehicleTrackRecord")
    public PointVo getVehicleTrackRecord() {
        return vehicleTrackRecordService.getVehicleTrackRecord();
    }

    @GetMapping("/getVehicleTrackRecordList")
    @Operation(summary = "getVehicleTrackRecordList")
    public List<VehicleTrackRecordOutVo> getVehicleTrackRecordList() {
        return vehicleTrackRecordService.getVehicleTrackRecordList();
    }


//    public static void main(String[] args) {
//        try {
//            // 方式1：简单GET请求
//            String result = HttpUtil.get("http://47.99.69.205:13000/record/getVehicleTrackRecordList", 5000); // 5秒超时

    /// /            String result = HttpUtil.get("ws://47.99.69.205:13000/ws"); // 5秒超时
//            if (StringUtils.isEmpty(result)) return;
//            // 使用 Hutool 解析 JSON 数组
//            JSONArray jsonArray = JSONUtil.parseArray(result);
//            // 遍历数组中的每个对象
//            for (int i = 0; i < jsonArray.size(); i++) {
//                JSONObject jsonObject = jsonArray.getJSONObject(i);
//                // 提取经纬度信息
//                BigDecimal longitude = jsonObject.getBigDecimal("longitude");
//                BigDecimal latitude = jsonObject.getBigDecimal("latitude");
//                // 创建点对象并添加到列表
//                VehicleTrackRecordOutVo point = new VehicleTrackRecordOutVo("ONE", longitude, latitude);
//                System.out.println(point);
//            }
//        } catch (Exception e) {
//            log.info(e.getMessage());
//        }
//    }




}
